feat(vcs): surface detected VCS in arc which --json - #59
Merged
Conversation
Add `vcs.Detect` helper that walks the filesystem (no binary invocations) to identify git and/or jj repos in stable order. Wire it into `arc which` via a typed `whichResult` struct so the `vcs` field (always present, never null) appears in JSON output and a `VCS:` line appears in human-readable output when a system is detected.
The which --json output gained a `vcs` array field, which breaks the two integration tests that unmarshaled the output into map[string]string (arrays can't decode into string values). Switch both to typed structs: TestWhichJsonOutput now also asserts vcs is present as a non-null array; TestWhichFromSymlinkAndRealPath decodes only the project_id it compares.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surfaces the detected version-control system(s) in
arc which, so agents and skills can ask "am I in git, jj, or a colocated repo?" without spawning their own probes. Arc already detects git/jj internally (PR #58) for project resolution — this exposes it.vcs.Detect(dir) []string— pure filesystem walk (no git/jj binary), reports systems in stable git-first order via the existinggitfs.FindGitEntry/jjfs.FindJJEntryprimitives.arc which --jsongains avcsarray, always present ([]when none, nevernull). Existing keys (project_id,source,project_name,warning) unchanged — the inlinemap[string]stringbecame a typedwhichResultstruct.whichgains aVCS:line (omitted when none detected).Design
Approved design:
docs/plans/2026-06-23-vcs-in-arc-which.md. Surface decision was hybrid — extendarc whichnow (smallest, fits its orientation purpose); defer a dedicatedarc vcscommand until a skill needsremote/main_repoexposed (YAGNI, additive/non-breaking).Tests
internal/vcs/vcs_test.gocovers all four cases with real fixtures (git init+ real.jjdirs): plain-git, native-jj, colocated, and neither (with an explicit non-nil assertion so JSON stays[]). Verified end-to-end: colocated repo →["git","jj"]in both JSON and human output.gofmt,golangci-lint, andgo test ./internal/vcs/... ./cmd/arc/...all clean. Pre-existing macOS-only symlink test failures ininternal/api/internal/gitfs(tracked in arc-0ek8.08g0rw) are unaffected — identical at the base commit; CI (Linux) is green.Closes arc-0ek8.05nd2z.